package com.example.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@RestController
@RequestMapping("/book")
public class BookList {
    @RequestMapping("getlist")
    public List<Books> getlist(){
        List<Books> list=new ArrayList<>();
        for(Books books:list){
            if(books.getStatus()=="1"){
                books.setStatus("可借阅");
            }else {
                books.setStatus("不可借阅");
            }
        }
        return list;
    }
    public List<Books> setbooklist(){
        int size=10;
        List<Books>list=new ArrayList<>(10);
        for(int i=0;i<size;i++){
            Books book=new Books();
            book.setId(i);
            book.setBookName("书名"+i);
            book.setAuthor("作者"+i);
            book.setPrice(new BigDecimal(new Random().nextInt(200)));
            book.setCount(new Random().nextInt(100));
            book.setStatus(String.valueOf(new Random().nextInt(1)+1));
            list.add(book);
        }
        return list;
    }
}
